Page({
  data: {
      money: "",
      capitalMoney: "",
      setDot: 0,
      chaoguoxianzhi: !1,
      maxMoney: 0
  },
  onLoad: function() {
      var t = wx.getMenuButtonBoundingClientRect();
      console.log(t);
  },
  inputMoney: function(t) {
      var e = 0;
      if (0 === this.data.maxMoney) {
          var n = t.currentTarget.dataset.num;
          e = this.data.money + n, console.log("没有超过最大"), console.log(e);
      } else e = this.data.maxMoney, console.log("超过最大"), console.log(e);
      if (-1 !== e.indexOf(".") && (console.log("现在这个数值是小数"), e.split(".")[1].length > 2)) {
          wx.showToast({
              title: "最多保留两位小数！",
              icon: "none",
              duration: 2e3
          });
          var o = this.saveTwoNum(e, 2);
          console.log(o), e = o;
      }
      this.changeMoneyToChinese(e), this.setData({
          money: e
      });
  },
  saveTwoNum: function(t, e) {
      var n = (t = t.toString()).indexOf(".");
      return t = -1 !== n ? t.substring(0, e + n + 1) : t.substring(0), parseFloat(t).toFixed(e);
  },
  inputDot: function(t) {
      var e = this.data.setDot + 1;
      if (console.log(e), 1 == e) {
          var n = t.currentTarget.dataset.num, o = this.data.money + n;
          console.log(o), this.setData({
              money: o,
              setDot: e
          });
      } else wx.showToast({
          title: "错误输入！",
          icon: "none",
          duration: 2e3
      });
  },
  delAll: function() {
      this.setData({
          money: "",
          capitalMoney: "",
          setDot: 0,
          maxMoney: 0
      });
  },
  delete: function() {
      var t = String(this.data.money);
      if (this.setData({
          maxMoney: 0
      }), console.log(this.data.money), "" == t) wx.showToast({
          title: "没有可删除的！",
          icon: "none",
          duration: 2e3
      }); else {
          var e = t.substring(t.length - 1), n = t.substring(0, t.length - 1);
          console.log(e), console.log(n), this.changeMoneyToChinese(n), "" == n && (console.log(1111), 
          this.setData({
              capitalMoney: ""
          })), "." == e ? this.setData({
              setDot: 0,
              money: n
          }) : this.setData({
              money: n
          });
      }
  },
  changeMoneyToChinese: function(t) {
      var e, n, o, a = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"), s = new Array("", "拾", "佰", "仟"), i = new Array("", "万", "亿"), r = new Array("角", "分"), l = "";
      if ("" == t) return "";
      if (t = parseFloat(t), console.log(t >= 999999999.99), t >= 999999999.99) {
          wx.showToast({
              title: "最多到亿哦！",
              icon: "none",
              duration: 2e3
          });
          var c = t.substring(0, t.length - 1);
          return console.log(c), this.setData({
              chaoguoxianzhi: !0,
              maxMoney: t
          }), "";
      }
      if (0 == t) return l = a[0] + "元";
      if (-1 == (t = t.toString()).indexOf(".") ? (e = t, n = "") : (e = (o = t.split("."))[0], 
      n = o[1].substr(0, 2)), parseInt(e, 10) > 0) {
          for (var g = 0, h = e.length, u = 0; u < h; u++) {
              var f = e.substr(u, 1), m = h - u - 1, y = m / 4, p = m % 4;
              "0" == f ? g++ : (g > 0 && (l += a[0]), g = 0, l += a[parseInt(f)] + s[p]), 0 == p && g < 4 && (l += i[y]);
          }
          l += "元";
      }
      if ("" != n) for (var d = n.length, M = 0; M < d; M++) {
          var x = n.substr(M, 1);
          "0" != x && (l += a[Number(x)] + r[M]);
      }
      "" == l && (l += a[0] + "元"), console.log(l), this.setData({
          capitalMoney: l
      });
  },
  copy: function() {
      var t = this.data.capitalMoney;
      wx.setClipboardData({
          data: t,
          success: function(t) {}
      });
  },
  onShareAppMessage: function(t) {
      this.setData({
          imageUrl: "http://file.scjrh.net/hammer/dxx.jpg",
          path: "pages/upcasing/upcasing"
      });
      var e = {
          title: "给你分享一个超好用的金额大写转换工具",
          path: this.data.path,
          imageUrl: this.data.imageUrl,
          success: function(t) {
              t.errMsg;
          },
          fail: function() {
              "shareAppMessage:fail cancel" == res.errMsg || res.errMsg;
          }
      };
      return t.from, e;
  },
  onShareTimeline: function() {
      return {
          title: "给大家推荐一个金额大写转换工具",
          imageUrl: "http://file.scjrh.net/hammer/logo.png"
      };
  }
});